package org.thanos.demo.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.thanos.demo.model.Customer;
import org.thanos.demo.service.CustomerService;

import java.util.Collections;
import java.util.List;
import java.util.Map;

@RestController
public class HelloController {

    private static final Logger logger = LoggerFactory.getLogger(HelloController.class);

    @Autowired
    private CustomerService customerService;

    @GetMapping("/count")
    public Map<String, Object> count() {
        return Collections.singletonMap("result", customerService.queryCount());
    }

    @GetMapping("/insert")
    public Map<String, Object> insert() {
        customerService.insert();
        return Collections.singletonMap("result",true);
    }

    @GetMapping("/findAll")
    public List<Customer> findAll(){
        return customerService.findAll();
    }

}
